package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;
                                                                                                                                                                                import com.ruoyi.common.utils.DateUtils;
            import org.springframework.stereotype.Service;
    import com.ruoyi.bizsys.mapper.MonitorLogMapper;
import com.ruoyi.bizsys.domain.MonitorLog;
import com.ruoyi.bizsys.service.IMonitorLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * 监控日志Service业务层处理
 *
 * @author african-loan
 * @date 2021-12-30
 */
@Service
public class MonitorLogServiceImpl extends ServiceImpl<MonitorLogMapper,MonitorLog> implements IMonitorLogService {

    /**
     * 查询监控日志
     *
     * @param id 监控日志ID
     * @return 监控日志
     */
    @Override
    public MonitorLog selectMonitorLogById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询监控日志列表
     *
     * @param monitorLog 监控日志
     * @return 监控日志
     */
    @Override
    public List<MonitorLog> selectMonitorLogList(MonitorLog monitorLog) {
        return this.list(new QueryWrapper<>(monitorLog).last("order by id desc"));
    }

    /**
     * 新增监控日志
     *
     * @param monitorLog 监控日志
     * @return 结果
     */
            @Override
    public int insertMonitorLog(MonitorLog monitorLog) {
                                                                                                                                                                                                                                                                                                        monitorLog.setCreateTime(DateUtils.getNowDate());
                                                                    return baseMapper.insert(monitorLog);
    }

    /**
     * 修改监控日志
     *
     * @param monitorLog 监控日志
     * @return 结果
     */
            @Override
    public int updateMonitorLog(MonitorLog monitorLog) {
                                                                                                                                                                                                                                                                                                                                                monitorLog.setUpdateTime(DateUtils.getNowDate());
                            return baseMapper.updateById(monitorLog);
    }

    /**
     * 批量删除监控日志
     *
     * @param ids 需要删除的监控日志ID
     * @return 结果
     */
            @Override
    public int deleteMonitorLogByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除监控日志信息
     *
     * @param id 监控日志ID
     * @return 结果
     */
    @Override
    public int deleteMonitorLogById(Long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public int getMonitForAnHourCount() {
        return baseMapper.getMonitForAnHourCount();
    }

}
